package JavaBianChengJiChu;

import java.util.Random;
import java.util.Scanner;

public class chaishuziyouxi {
    public static void main(String[] args) {
        Random random=new Random();
        //int number=random.nextInt(100)+1;
        int number1=(int)(Math.random()*100)+1;

        Scanner scanner=new Scanner(System.in);

        boolean flag=true;
        int i=0;
        while(flag=true){
            System.out.println("请输入你要输入的数字");
            int ret= scanner.nextInt();
            if(ret>number1){
                System.out.println("猜大了，重新猜");
                i++;
            }
            else if(ret<number1){
                System.out.println("猜小了,重新猜");
                i++;
            }
            else{
                System.out.println("恭喜你，猜对了，大小是"+number1+"一共猜了"+i+"次");
                flag=false;
                break;
            }
        }
    }
}
